package com.example.demo.mapper;


import com.example.demo.entity.*;
import org.apache.ibatis.annotations.*;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface UserMapper {

//    @Select("select * from runoob_tbl")
//    List<Table_demo> findAll();
//
//    @Update("INSERT INTO runoob_tbl (runoob_id, runoob_title, runoob_author, submission_date) VALUES (#{runoob_id},#{runoob_title},#{runoob_author},#{submission_date})")
//    @Transactional
//    void save(Table_demo table_demo);
//
//    @Select("select * from runoob_tbl order by runoob_id desc limit 1")
//    Table_demo findLast();

    //管理员模块部分begin
    @Select("select * from user_basic_info")
    List<UserBasicInfo> find_all_user_basic_info();

    @Select("select user_id from user_basic_info where user_phone = #{phone}")
    String get_user_id(@Param("phone") String phone);

    @Select("select * from user_basic_info where user_id in ( select user_id from user_basic_info where user_phone = #{userphone})")
    List<UserBasicInfo> find_user_by_id(@Param("userphone")String userphone);

    @Update("update user_basic_info" +
            "    set user_nickname = #{user_nickname}," +
            "      user_type = #{user_type},"+
            "     user_phone = #{user_phone},"+
            "     user_password= #{user_password}"+
            "    where user_id = #{user_id} ")
    boolean update_user_basic(UserBasicInfo userBasicInfo);

    @Select("select * from user_feedback_info where user_id = #{userid}")
    List<UserFeedbackInfo> findFeedBackByid(@Param("userid")String userid);

    @Update("update user_feedback_info"+
            "   set is_viewed = 1"+
            "   where _Id = #{feedbackid}")
    boolean update_feedback_by_id(@Param("feedbackid")Integer feedbackid);

    @Select("select * from user_feedback_info where is_viewed = 0")
    List<UserFeedbackInfo> find_unviewed();

    @Select("select * from user_feedback_info where is_viewed = 1")
    List<UserFeedbackInfo> find_viewed();

//管理员模块end

    //用户模块begin
    @Select("select * from user_basic_info where user_phone = #{myphone}")
    UserBasicInfo find_my_user_basic_info(String myphone);
    //用户模块end









}
